class TreeNode<T> {
    value: T; // 节点存储的数据

    next: TreeNode<T> | null = null; // 指向下一个节点的指针
    return: TreeNode<T> | null = null; // 指向上一个节点的指针（双向链表）
    children: TreeNode<T> | null = null; // 指向子节点的指针
    sibling: TreeNode<T> | null = null; // 指向兄弟节点的指针

    constructor(value: T) {
        this.value = value;
    }

}
export default class TreeNodeList<T> {
    head: TreeNode<T>;
    currentNode: TreeNode<T>;
    constructor(value: T) {
       this.head=new TreeNode(value)
       this.currentNode =  this.head;
    }

    addChildren(value:T){
      const  treeNode=new TreeNode(value)
      treeNode.return=this.currentNode;
      this.currentNode.next=treeNode;
      this.currentNode=treeNode
   }

   addSibling(value:T){
    const  treeNode=new TreeNode(value)
    treeNode.return=this.currentNode.sibling
    this.currentNode.sibling=treeNode;
    this.currentNode=treeNode
 }
}





